package com.freejava.test_freemarker.controller;

import com.freejava.test_freemarker.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 国家控制器
 */
@Controller
public class CountryController {

    @Autowired
    private CountryService countryService;

    @RequestMapping(value = "/country/{id}")
    public String findCountryById(Model m, @PathVariable("id") Long id) {
        m.addAttribute("countries", countryService.findCountryById(id));
        return "country";
    }
}
